package com.zx.mobile.context;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.zx.platform.service.domain.DirectoryModel;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 14-3-8
 * Time: 下午2:41
 * To change this template use File | Settings | File Templates.
 */
public class GetDictListByKeyELTag extends TagSupport {

    /**
     * 字典分类
     */
    protected String key;

    /**
     * value
     */
    protected String var;

    //执行
    public int doStartTag() throws JspException {
        String out = null;
        //字典上下文
        List<DirectoryModel> directoryModelList = DirectoryInfoContext.getDirectInfoList();
        List<DirectoryModel> list = new ArrayList<DirectoryModel>();
        for (DirectoryModel directoryModel : directoryModelList) {
            if (directoryModel.getDirKey().equals(key)) {
                list.add(directoryModel);
            }
        }
        pageContext.setAttribute(var, list);

        return SKIP_BODY;
    }

    //结果
    public int doEndTag() {
        //、、、、
        return EVAL_PAGE;
    }

    public String getVar() {
        return var;
    }

    public void setVar(String var) {
        this.var = var;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}